<template>
  <div>
    <TitleA>精品歌单</TitleA>

    <div class="play_list_box">
      <div
        class="play_item"
        @click="playItemClick(pld)"
        v-for="(pld, index) in playListData"
        :key="index"
      >
        <PlayCard :option="pld"></PlayCard>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, ref } from "vue";
export default defineComponent({
  name: "PlayList",
});
</script>
<script lang="ts" setup>
import TitleA from "@/components/Title/titleA.vue";
import PlayCard from "./components/playCard/index.vue";
import { getPlayListApi } from "@/api/home.ts";
import { useRouter } from "vue-router";
import { usePlayStore } from "@/store";

const router = useRouter();
const playStore = usePlayStore();

// 歌单点击事件
const playItemClick = (pld: any) => {
  router.push({
    path:'/PlayDetail'
  })
  playStore.playInfo = pld
};

// 精品歌单数据
const playListData = ref([]);

// 获取精品歌单数据
const getPlayListFunc = async () => {
  await getPlayListApi({ limit: 20 }).then((res) => {
    playListData.value = res.playlists;
  });
  console.log(playListData.value);
};

onMounted(() => {
  getPlayListFunc();
});
</script>

<style lang="scss" scoped>
.play_list_box {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  // justify-content: space-between;

  .play_item {
    // margin-top: 20px;
    // margin-right: 18px;
    padding: 10px;
    width: 180px;
    // border: 1px solid red;
    margin-top: 10px;
  }
}
</style>
